package com.sky.service.impl;

import com.sky.constant.StatusConstant;
import com.sky.dto.SetmealDTO;
import com.sky.entity.SetmealDish;
import com.sky.mapper.SetmealMapper;
import com.sky.service.SetmealService;
import com.sky.vo.DishItemVO;
import com.sky.vo.SetmealVO;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SetmealServiceImpl implements SetmealService {

    @Resource
    private SetmealMapper setmealMapper;

    /**
     * @description: 查询套餐列表
     * @author: tanbobin
     * @date: 2024/6/5 10:59
     * @param:
     * @param categoryId
     * @return:
     * @return java.util.List<com.sky.vo.SetmealVO>
     **/
    @Cacheable(cacheNames = "setmeal:cache", key = "#categoryId")
    @Override
    public List<SetmealVO> listCategoryIdWithSetmeal(Long categoryId) {
        SetmealDTO setmealDTO = SetmealDTO.builder().categoryId(categoryId).status(StatusConstant.ENABLE).build();
        return setmealMapper.querySetmealList(setmealDTO);
    }

    /**
     * @description: 查询套餐关联的菜品信息
     * @author: tanbobin
     * @date: 2024/6/5 11:15
     * @param:
     * @param setmealId
     * @return:
     * @return java.util.List<com.sky.vo.DishVO>
     **/
    @Cacheable(cacheNames = "setmeal:cache", key = "#setmealId")
    @Override
    public List<DishItemVO> listSetmealByIdWithSetmealDish(Long setmealId) {
        return setmealMapper.listSetmealByIdWithSetmealDish(setmealId);
    }
}
